import numpy as np
import matplotlib.pyplot as plt
import pandas as pd
print('imported successfully')
df=pd.read_csv('Data_Collisions.csv')
df.head()
import seaborn as sns
weather = df['WEATHER']
weather
weather.head
plt.figure(figsize=(15,15))
ax = sns.countplot(x="WEATHER", data=df)
More accidents have been reported in clear weather followed by overcast and rainy weather
plt.figure(figsize=(15,15))
ax = sns.countplot(x="ROADCOND", data=df)
More accidents have been reported in dry road conditions followed by wet and unknown circumstances
plt.figure(figsize=(15,15))
ax = sns.countplot(x="LIGHTCOND", data=df)
More accidents have been reported in daylight followed by street light and unknown circumstances
plt.figure(figsize=(15,25))
ax = sns.countplot(x="LOCATION", data=df)
df['LOCATION'].count()
df.groupby('LOCATION').count()
Location = df['LOCATION'].value_counts()
Location
df.head()
df.info
Location.describe
df2 = pd.DataFrame(data=Location)
df2
Location.describe
#Creating a dictionary for LIGHTCOND
light = {'Daylight': 1,'Dark - Street Lights On': 2,'Dusk': 3, 'Dark - No Street Lights': 4 }
light
df['LIGHTCOND'] = df['LIGHTCOND'].map(light)
df['LIGHTCOND']
z = df['LIGHTCOND']
z
import plotly.graph_objects as go
import seaborn as sns
#from ggplot import *
print('imported successfully')
#creating the heatmap
fig = go.Figure(data=go.Heatmap(
x = df['WEATHER'],
y = df['LOCATION'],
z = z,
type = 'heatmap',
colorscale = 'Viridis', hoverongaps = False))
fig.show()